class RubricaTelefonica < ActiveRecord::Base
  acts_as_paranoid unless SHOW_DELETED
  ## UNION rubrica_telefonica
  #(SELECT ragione_sociale as nome, '' as contatto, telefono, '' as cellulare, fax, mail, deleted_at, 'partner' as tipo, descrizione, chiavi_ricerca  FROM partners) UNION (SELECT concat(cognome, ' ', nome) as nome, '' as contatto, telefono, cellulare, '' as fax, mail, deleted_at, 'personale' as tipo, '' as descrizione, chiavi_ricerca FROM personale) UNION (SELECT (select ragione_sociale from partners where partners.id = contatti.contatto_ref_id) as nome, name as contatto,telefono, cellulare, fax, mail, deleted_at, 'contatti' as tipo, (select descrizione from partners where partners.id = contatti.contatto_ref_id) as descrizione, (select chiavi_ricerca from partners where partners.id = contatti.contatto_ref_id) as chiavi_ricerca FROM contatti where contatto_ref_id IS NOT NULL) ORDER by nome
  end
